<?php
/**
 * Router
 * 
 * @author RiderSx
 */
class xineForumRouter {
	public $type,
			$action,
			$params;
	
	public function __construct() {
		$types = array(
			'ajax',
			'xml',
			'rss',
			'atom'
		);
		
		$uri = $_SERVER['REQUEST_URI'];
		$uri = explode('/', $uri);
		$uri = array_slice($uri, xine::$config['routerOffset']+1);
		
		if(end($uri) == '') {
			unset($uri[count($uri)-1]);
		}
		
		if(in_array(end($uri), $types)) {
			$this->type = end($uri);
			unset($uri[count($uri)-1]);
		} else {
			$this->type = 'default';
		}
		
		if(empty($uri[0]))  $this->action = 'discussions';
		else $this->action = $uri[0];
		
		$this->params = array_slice($uri, 1);
	}
}